/**
 * Copyright (c) 2011 Nokia Corporation.
 */

#ifndef FILECOPYOPERATION_H
#define FILECOPYOPERATION_H

// Qt includes
#include <QFile>
#include <QFileInfoList>
#include <QString>
#include <QThread>


class FileCopyOperation : public QThread
{
    Q_OBJECT

public: // Construction and destruction
    explicit FileCopyOperation(QObject *parent = 0);
    explicit FileCopyOperation(QFileInfoList sourceFiles,
                               QString targetRootPath,
                               QObject *parent = 0);
    virtual ~FileCopyOperation();

public:
    void setSourceFiles(QFileInfoList sourceFiles);
    void setTargetRootPath(const QString &targetRootPath);

protected: // From QThread
    void run();

private:
    QFile::FileError copy(QFile &sourceFile, const QString &target) const;

public slots:
    void cancel();

signals:
    void status(int currentIndex,
                qlonglong totalSizeCopied,
                const QString &fileCopied,
                const QString &fileStarting);
    void failed(QFile::FileError error, const QString &filename);
    void cancelled();

private: // Data
    QFileInfoList m_sourceFiles;
    QString m_targetRootPath;
    bool m_cancel;
};


#endif // FILECOPYOPERATION_H

// End of file.
